<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>ROSS: core/tw-timing.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <a href="https://github.com/ROSS-org/ROSS">
   <div id="projectname">ROSS
   </div>
   </a>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_af18cf245e3394ab3b436135935cfd6e.html">core</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">tw-timing.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="tw-timing_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &lt;<a class="code" href="ross_8h.html">ross.h</a>&gt;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="keywordtype">void</span></div>
<div class="line"><a name="l00004"></a><span class="lineno"><a class="line" href="tw-timing_8c.html#abb6fbfaf29e819dca59955bfda375992">    4</a></span>&#160;<a class="code" href="tw-timing_8c.html#abb6fbfaf29e819dca59955bfda375992">tw_wall_now</a>(<a class="code" href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a> * t)</div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;{</div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;        <span class="keywordflow">if</span>(0 != gettimeofday((<span class="keyword">struct</span> timeval *)t, NULL))</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;                <a class="code" href="ross-extern_8h.html#a49ed2388aaae26e43280b7909c834aaa">tw_error</a>(<a class="code" href="ross-extern_8h.html#afffdf140f2c492f61546ad783833f127">TW_LOC</a>, <span class="stringliteral">&quot;Unable to get time of day!&quot;</span>);</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;}</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="keywordtype">void</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="tw-timing_8c.html#a47c205fb13e816aa4a0252ab2e7cd094">   11</a></span>&#160;<a class="code" href="tw-timing_8c.html#a47c205fb13e816aa4a0252ab2e7cd094">tw_wall_sub</a>(<a class="code" href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a> * r, <a class="code" href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a> * a, <a class="code" href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a> * b)</div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;{</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;        r-&gt;tv_sec = a-&gt;tv_sec - b-&gt;tv_sec;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;        r-&gt;tv_usec = a-&gt;tv_usec - b-&gt;tv_usec;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;        <span class="keywordflow">if</span> (r-&gt;tv_usec &lt; 0)</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;        {</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;                r-&gt;tv_sec--;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;                r-&gt;tv_usec += 1000000;</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;        }</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;}</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="keywordtype">double</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="tw-timing_8c.html#ae0f8e95d53bcbe6803081588d3058146">   24</a></span>&#160;<a class="code" href="tw-timing_8c.html#ae0f8e95d53bcbe6803081588d3058146">tw_wall_to_double</a>(<a class="code" href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a> * t)</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;{</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        <span class="keywordflow">return</span> (<span class="keywordtype">double</span>)t-&gt;tv_sec + (((double)t-&gt;tv_usec) / 1000000);</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;}</div>
<div class="ttc" id="ross-extern_8h_html_afffdf140f2c492f61546ad783833f127"><div class="ttname"><a href="ross-extern_8h.html#afffdf140f2c492f61546ad783833f127">TW_LOC</a></div><div class="ttdeci">#define TW_LOC</div><div class="ttdef"><b>Definition:</b> <a href="ross-extern_8h_source.html#l00164">ross-extern.h:164</a></div></div>
<div class="ttc" id="ross-extern_8h_html_a49ed2388aaae26e43280b7909c834aaa"><div class="ttname"><a href="ross-extern_8h.html#a49ed2388aaae26e43280b7909c834aaa">tw_error</a></div><div class="ttdeci">void tw_error(const char *file, int line, const char *fmt,...) NORETURN</div><div class="ttdef"><b>Definition:</b> <a href="tw-util_8c_source.html#l00074">tw-util.c:74</a></div></div>
<div class="ttc" id="tw-timing_8c_html_abb6fbfaf29e819dca59955bfda375992"><div class="ttname"><a href="tw-timing_8c.html#abb6fbfaf29e819dca59955bfda375992">tw_wall_now</a></div><div class="ttdeci">void tw_wall_now(tw_wtime *t)</div><div class="ttdef"><b>Definition:</b> <a href="tw-timing_8c_source.html#l00004">tw-timing.c:4</a></div></div>
<div class="ttc" id="tw-timing_8c_html_a47c205fb13e816aa4a0252ab2e7cd094"><div class="ttname"><a href="tw-timing_8c.html#a47c205fb13e816aa4a0252ab2e7cd094">tw_wall_sub</a></div><div class="ttdeci">void tw_wall_sub(tw_wtime *r, tw_wtime *a, tw_wtime *b)</div><div class="ttdef"><b>Definition:</b> <a href="tw-timing_8c_source.html#l00011">tw-timing.c:11</a></div></div>
<div class="ttc" id="tw-timing_8h_html_afb3cc3360b4871f1d990048a71b909c6"><div class="ttname"><a href="tw-timing_8h.html#afb3cc3360b4871f1d990048a71b909c6">tw_wtime</a></div><div class="ttdeci">struct timeval tw_wtime</div><div class="ttdef"><b>Definition:</b> <a href="tw-timing_8h_source.html#l00004">tw-timing.h:4</a></div></div>
<div class="ttc" id="ross_8h_html"><div class="ttname"><a href="ross_8h.html">ross.h</a></div></div>
<div class="ttc" id="tw-timing_8c_html_ae0f8e95d53bcbe6803081588d3058146"><div class="ttname"><a href="tw-timing_8c.html#ae0f8e95d53bcbe6803081588d3058146">tw_wall_to_double</a></div><div class="ttdeci">double tw_wall_to_double(tw_wtime *t)</div><div class="ttdef"><b>Definition:</b> <a href="tw-timing_8c_source.html#l00024">tw-timing.c:24</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
